#!/bin/bash

PlistBuddy="/usr/libexec/PlistBuddy"
plist="Winbox-mac.app/Contents/Info.plist"
app_name=$($PlistBuddy -c "Print:CFBundleName" $plist)
version=$($PlistBuddy -c "Print:CFBundleVersion" $plist)
dir="Releases/$version"

check_result() {
  if [ "$1" == "0" ]; then
    printf " Done.\n"
  else
    printf " Failed.\n"
    exit 1
  fi
}

printf "Creating release for version $version.\n"

printf "Creating release directory ($dir):"
mkdir -p $dir
check_result $?

printf "Creating zip:"
zip -qyr9 "$dir/$app_name-$version.zip" $app_name.app
check_result $?
